package stancel.peter.smartsilencer.background;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * Sluzi na spustenie aplikacie pri starte systemu. 
 * @author Peter Stancel
 */
public class StartupBroadcastReceiver extends BroadcastReceiver{

	/**
	 * Spusti aplikaciu pri starte systemu ak je to povolene v nastaveniach aplikacie.
	 */
	@Override
	public void onReceive(Context context, Intent intent) {
		if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
			SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
			boolean startAtBoot = preferences.getBoolean("smart_silencer_start_at_boot", true);
			if(startAtBoot){
//				Bundle bundle = new Bundle();
//				bundle.putBoolean("smartsilencer_startatboot", true);
				Intent checkingIntent = new Intent(context, CheckingService.class);
//				intent.putExtras(bundle);
				context.startService(checkingIntent);
			}
		}
	}
}
